package com.mes.service.impl;

import com.mes.entity.Energy;
import com.mes.service.EnergyService;
import com.mes.mapper.EnergyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.List;

/**
* @author DELL
* @description 针对表【energy】的数据库操作Service实现
* @createDate 2024-09-18 09:37:00
*/
@Service
public class EnergyServiceImpl implements EnergyService {

    @Autowired
    private EnergyMapper energyMapper;

    @Override
    public List<Energy> listByLike(String name , String address) {
        return energyMapper.listByLike(name,address);
    }

    @Override
    public int removeById(String id) {
        return energyMapper.removeById(id);
    }

    @Override
    public int insertEnergy(Energy energy) {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.util.Date date =new java.util.Date();
        String str= sdf.format(date);
        energy.setReporttime(str);
        return energyMapper.insertEnergy(energy);
    }

    @Override
    public int updateById(Energy energy) {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.util.Date date =new java.util.Date();
        String str= sdf.format(date);
        energy.setReporttime(str);
        return energyMapper.updateById(energy);
    }
}




